<template>
	<view class="container">
		<view class="list" v-if="list.length > 0">
			<view class="box" hover-class="hoverClass" v-for="item in list" :key="item.id" @click="goDetail(item)">
				<view class="title">
					<view class="time">{{ item.time }}</view>
					<view class="right">
						<text class="status status1" v-if="item.status == 1">待处理</text>
						<text class="status status2" v-else-if="item.status == 2">处理中</text>
						<text class="status status3" v-else-if="item.status == 3">已处理</text>
						<uni-icons type="right" size="16" color="#bbb"></uni-icons>
					</view>
				</view>
				<view class="detail">{{ item.detail }}</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image class="image" src="@/static/img/empty.png" mode="aspectFit"></image>
			<view class="emptyWord">无报修记录</view>
		</view>
		<view class="addBtn" @click="addFix">
			<uni-icons type="plusempty" size="32" color="#fff"></uni-icons>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [
				{
					id: 0,
					detail: '窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了窗户坏了',
					time: '2023-09-08 10:52',
					status: 1
				},
				{
					id: 1,
					detail: '门坏了',
					time: '2023-09-08 10:52',
					status: 2
				},
				{
					id: 2,
					detail: '热水器坏了',
					time: '2023-09-08 10:52',
					status: 3
				}
			]
		};
	},
	onShow() {},
	onPullDownRefresh() {
		setTimeout(() => {
			this.stopPull();
		}, 1000);
	},
	methods: {
		stopPull() {
			uni.stopPullDownRefresh();
		},
		addFix() {
			uni.navigateTo({
				url: '/pages/mine/fix/add'
			});
		},
		goDetail(item) {
			console.log(item);
			uni.navigateTo({
				url: '/pages/mine/fix/detail?detail=' + item.detail
			});
		}
	}
};
</script>

<style lang="scss">
.container {
	padding: 0 40rpx;
	.list {
		.box {
			background: #fff;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			box-shadow: $uni-shadow-base;
			padding: 26rpx;
			.title {
				display: flex;
				justify-content: space-between;
				align-items: center;
				.time {
					font-size: 28rpx;
					font-weight: bold;
				}
				.status {
					font-size: 26rpx;
					margin-right: 10rpx;
					&.status1 {
						color: $uni-error;
					}
					&.status2 {
						color: $uni-warning;
					}
					&.status3 {
						color: $uni-primary;
					}
				}
			}
			.detail {
				font-size: 28rpx;
				color: $uni-secondary-color;
				margin-top: 10rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}
	}
}
</style>
